#include <iostream>
#include <memory>

class Date
{
public:
	Date(int year = 1, int month = 1, int day = 1)
		:_year(year), _month(month), _day(day)
	{}
	~Date() 
	{
		std::cout << "~Date()" << std::endl;
	}
private:
	int _year;
	int _month;
	int _day;
};

template<class T>
class SmartPtr
{
public:
	SmartPtr(T* ptr)
		:_data(ptr)
	{}

	~SmartPtr()
	{
		std::cout << "~SmartPtr()" << std::endl;
		delete _data;
	}

	T& operator()()
	{
		return *_data;
	}

	T* operator->()
	{
		return _data;
	}

private:
	T* _data;
};

template<class T>
class Unique_ptr
{
public:
	Unique_ptr(T* ptr)
		:_ptr(ptr)
	{}
	~Unique_ptr()
	{
		if (_ptr)
		{
			delete _ptr;
		}
	}

	T& operator*()
	{
		return *_ptr;
	}

	T* operator->()
	{
		return _ptr;
	}

	Unique_ptr(const Unique_ptr<T>& sp) = delete;
	Unique_ptr<T>& operator=(const Unique_ptr<T>& sp) = delete;
	Unique_ptr(Unique_ptr<T>&& sp)
		:_ptr(sp._ptr)
	{
		sp._ptr = nullptr;
	}

	Unique_ptr<T>& operator=(Unique_ptr<T>&& sp)
	{
		delete _ptr;
		_ptr = sp._ptr;
		sp._ptr = nullptr;
	}

private:
	T* _ptr;
};



int main()
{
	// SmartPtr<Date> sp = new Date();
	std::shared_ptr<Date> sp1(new Date(1949, 10, 1));
	std::shared_ptr<Date> sp2(sp1);
	std::shared_ptr<Date> sp3(sp2);
	std::cout << sp1.use_count() << std::endl;

	// decltype

	return 0;
}